<?php require VIEW_PATH.'/header.php';?>
<body>
<div class="hd-menu-list">
    <ul>
        <li class="active">
        	<a href="#">添加管理</a>
        </li>
        <li class="">
            <a href="{{U('index',array('goods_id'=>$_GET['goods_id']))}}">返回列表</a>
        </li>
    </ul>
</div>
<form method="post">
<input type="hidden" name="hd_shop_goods_goods_id" value="{{$good}}">
<table class="hd-table hd-table-list">
    <thead>
    <tr style="text-align: center">
    <?php foreach ($attrTitle as $v):?>
        <td>{{$v['attr_name']}}</td>
    <?php endforeach;?>
        <td>货号</td>
        <td>库存</td>
        <td>操作</td>
    </tr>
    </thead>
    <tbody>    
    <tr style="text-align: center" name="con">
    <?php foreach ($attrTitle as $v):?>
        <td>
            <select name="store_attr_id[{{$v['attr_id']}}][]" id="">
            <?php foreach ($goodsAttr as $a):?>
                <?php if($a['hd_shop_attr_attr_id']==$v['attr_id']):?>
                    <option value="{{$a['goods_attr_id']}}">&nbsp;&nbsp;&nbsp;&nbsp;{{$a['attr_value']}}</option>
                <?php endif;?>
            <?php endforeach;?>
            </select>
        </td>
        <?php endforeach;?> 
        <td>
            <input type="text" name="goods_sn[]">
        </td>
        <td>
            <input type="text" name="store_num[]">
        </td>
        <td class="hd-w150">
            <button type="button" onclick="addGoodsStore(this)" style="display:inline-block;margin-left:10px;box-shadow: 0 0 5px #ccc;border-radius: 0;font-weight: bold; width:20px;height:20px;line-height:15px;text-align:center;">+</button>
        </td>
    </tr>
    </tbody>
</table>
<button type="submit" class="hd-btn hd-btn-primary">提交</button>
</form>
</body>
<script type="text/javascript">
function addGoodsStore(obj)
{
    //复制tr行
    var tr = $(obj).parents('tr').eq(0).clone();
    tr.find('button').attr('onclick','removeGoodsStore(this)').html('-');
    //插入行原tr行后面
    $(obj).parents('tr').eq(0).after(tr);
}
function removeGoodsStore(obj)
{
    $(obj).parents('tr').eq(0).remove();
}
</script>
</script>
</html>